package gson.emlog.adapter;

import gson.emlog.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 自定义SpinnerAdapter
 * @author GodSon
 *
 */
public class SpinnerAdapter extends BaseAdapter {
	private String[] items;
	private Context mContext;

	public SpinnerAdapter(Context mContext,String[] items) {
		this.items = items;
		this.mContext = mContext;
	}
	public int getCount() {
		return items.length;
	}

	public Object getItem(int position) {
		return items[position];
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater lif = LayoutInflater.from(mContext);
		convertView = lif.inflate(R.layout.spinneritem, null);
		if(convertView!=null){
			TextView txv = (TextView) convertView.findViewById(R.id.spnItem);
			txv.setText(items[position]);
		}
		return convertView;
	}

}
